#include <bits/stdc++.h>
using namespace std;

using ll = long long int;

#if 0
int main()
{
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    bool isa = false, isb = false;
    ll ret = 0;
    if (a > b)
        isa = true;
    else
        isb = true;
    if (isa)
    {
        // 1号礼包

        int acopy = n;
        int bcopy = m;
        while (acopy >= 2 && bcopy >= 1)
        {
            ret += a;
            acopy -= 2;
            bcopy -= 1;
        }
        while (acopy >= 1 && bcopy >= 2)
        {
            ret += b;
            acopy -= 1;
            bcopy -= 2;
        }
    }
    else
    {
        int acopy = n;
        int bcopy = m;
        while (acopy >= 1 && bcopy >= 2)
        {
            ret += b;
            acopy -= 1;
            bcopy -= 2;
        }
        while (acopy >= 2 && bcopy >= 1)
        {
            ret += a;
            acopy -= 2;
            bcopy -= 1;
        }
    }
    cout<<ret<<endl;
    return 0;
}
#endif

int main()
{
    ll n, m, a, b;
    cin >> n >> m >> a >> b;
    ll ret = 0;
    // 枚举第一个礼包数量
    for (int x = 0; x <= min(n / 2, m); x++)
    {
        int leftapple = n - x * 2;
        int leftother = m - x;
        ll tem = a * x + b * max(0, min(leftapple, leftother / 2));
        ret = max(ret, tem);
    }
    cout << ret << endl;
    return 0;
}